class Student(object):
    def __init__(self, name, score):
        self.__name = name
        self.__score = score

    def print_score(self):
        print('Name: {}, Score: {}'.format(self.__name, self.__score))


student = Student('miao', 90)
# __ 前缀的变量 被处理成私有变量
# student.__name='zhang'
print(student.print_score())


# print(student.print_score())

# 使用  type() 判断一个对象是什么类型


class SchoolStudent(Student):
    # 绑定静态变量属于  SchoolStudent
    area = "School"

    def __init__(self, name, score):
        # 调用父类的__init__ 方法
        super(SchoolStudent, self).__init__(name, score)
        self.__name = name
        self.__score = score

    def print_score(self):
        # 在字类的中调用父类对象的实例方法
        Student.print_score(self)
        print('SchoolStudent Name: {}, SchoolStudent Score: {}'.format(self.__name, self.__score))


school = SchoolStudent('zhang', 90)
school.print_score()

print(type(student) == Student)

import types


def fun():
    pass


print(type(fun) == types.FunctionType)

print(type(lambda x: x) == types.LambdaType)

print(type(x * x for x in range(10)) == types.GeneratorType)

print(type(213) == int)

print(type(213) == str)

# isinstance 判断是否是该类型或其子类

print(isinstance(213, int))

print(isinstance(student, Student))

print(isinstance(school, SchoolStudent))


class Animal(object):
    # 限制属性
    __slots__ = ('__name', '__age')

    def __init__(self, name, age):
        self.__name = name
        self.__age = age
